<?php
namespace app\index\controller;
use think\Db;
class Contact extends Base{
    public function contact(){
        $this->assign('system',$this->system_set());
        return $this->fetch();
    }
    public function message_add(){
        $param = input('post.');
        if(!empty(input("param.name"))){
        	$data['name']=$param['name'];
        }else{
            return json(['code' => 501, 'msg' => '姓名？']);
        }
        if(!empty(input("param.tel_phone"))){
        	$data['tel_phone']=$param['tel_phone'];
        }else{
            return json(['code' => 502, 'msg' => '电话？']);
        }
        $data['email']=$param['email'];
        $data['company']=$param['company'];
        $data['message']=$param['message'];
        $data['state']=1;
        $data['time']=time();
        $data['uptime']=time();
        $res=Db::name('message')->insert($data);
        if($res){
            return json(['code' => 200,'msg' => '成功']);
        }else{
            return json(['code' => 500,'msg' => '失败']);
        }
    }
}
